<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>homework6</title>
</head>
<body>
<pre>
    from functools import wraps
import datetime

def logging(filename = 'homework6.log'):
    def logs(function):
        @wraps(function)
        def LogInfo(*args, **kwargs):
            string = function.__name__ + ' call at ' + str(datetime.datetime.now())
            with open(filename,'a') as file:
                # 将日志打印到文件
                file.write(string+'\n')
            return function(*args,**kwargs)
        return LogInfo
    return logs

@logging(filename='homework6.log')
def myfun():
    print("函数执行...")


myfun()
</pre>
</body>
</html>